﻿#!/usr/bin/env python3

import subprocess

def main():
    '''
    Popen的一个例子: sub proc通过pipe向creator输出stdout.
    subporcess中的run, call, check_call, check_output等都是对Popen的简单封装.
    Popen主要特点是可以设定创建的sub process的stdin, stdout,和stderr.

    '''
    subproc = subprocess.Popen(["echo","hello, the word!"], shell=True, stdout=subprocess.PIPE)
    stdoutValue = subproc.communicate()[0].decode('utf-8')
    print('stdout:', stdoutValue)


if __name__=='__main__':
    main()
